<?php
include_once  "Source.php";

$filename  = "城主5月31号打点.csv";

$row = 0;
if (($handle = fopen($filename, "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000)) !== FALSE) {
        $num = count($data);
        $row++;
        if (1 == $row) {
            $fields = $data;
            continue;
        }

        for ($c=0; $c < $num; $c++) {
           $info[$fields[$c]] = $data[$c];
        }
        $list[$info['source']][$info['momo_id']] = 1;

    }
    fclose($handle);
}


$fp = fopen('城主5月31号打点统计.csv', 'w');
$fileds = ['source', 'source_name', 'number'];



foreach ($list as $k => $item) {
    $info = [$k, Source::SOURCE_NAME_LIST[$k] , count($item)];
    fputcsv($fp, $info);
}